package JsonInterface;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.Proxy;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.HashMap;

import JsonInterface.SocketThread;
import com.opensymphony.xwork2.ActionSupport;
import org.springframework.beans.factory.annotation.Autowired;




public class SocketControl extends ActionSupport {


	public Socket clientSocket;
	public ServerSocket serverSocket;

	public SocketControl( ) {
//		try {createSocket
//			DatagramSocket  server = new DatagramSocket(10001);
//			System.out.println("created UDP successfully");
//			udp_receive(server);
//		}catch (SocketException e) {
//			// TODO Auto-generated catch block
//
//			e.printStackTrace();
//		}
		/*************************TCP*************************/
		try {
			serverSocket = new ServerSocket(10021);//10000
			System.out.println("created TCP 10021 successfully");
			//	new PhoneDialer();
			receie();

		} catch (Exception e) {

			e.printStackTrace();
		}

	}
//	public void udp_receive(final DatagramSocket server){
//		 new Thread(new Runnable() {
//				@Override
//				public void run() {
//					// TODO Auto-generated method stub
//					new ZKP36_UDP(server);
//				}
//			}).start();
//	}

	public void receie( ) {
		while (true) {
			try {
				System.out.println("hhh2");
				System.out.println("accept...");
				clientSocket =serverSocket.accept();

				new SocketThread(clientSocket).start();

			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
